<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <button type="button" id="pre-analysis-btn">测试预解析</button>
</head>
<body>
<script>
    // 测试变量预解析: var变量会被预解析，声明提至函数首行，赋值不动
    document.querySelector("#pre-analysis-btn").onclick = () => {
        console.log("money", money);
        {
            var money = 100;
        }

        // 预解析: 将声明放在所在函数的首行，赋值保持原位
        /*
        var money;
        console.log("money", money);
        {
            money = 100;
        }
        */
    };
</script>
</body>
</html>